package com.powergisol.gis.controller;

import com.powergisol.gis.dto.DynamicColumnDTO;
import com.powergisol.gis.service.DynamicColumnService;
import com.powergisol.gis.service.TabMarkerColorService;
import com.powergisol.gis.util.Result;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 动态列
 */
@RestController
@RequestMapping("/dynamiccolumn")
public class DynamicColumnContrller {

    @Autowired
    DynamicColumnService dynamicColumnService;
    @Autowired
    TabMarkerColorService tabMarkerColorService;

    /**
     * 获取动态的字段
     * @return
     */
    @RequestMapping(value = "/getdynamiccolumn/{isUpdate}",method = RequestMethod.GET)
    public Result getDynamicColumn(@PathVariable("isUpdate") Integer isUpdate){
        DynamicColumnDTO dynamicColumnDTO = dynamicColumnService.getDynamicColumn(isUpdate);
        return new Result().success(dynamicColumnDTO);
    }

    /**
     * 获取土层的名称
     * @param serviceId
     * @return
     */
    @RequestMapping(value = "/gettcmc",method = RequestMethod.GET)
    public Result getTCMS(@RequestParam("serviceId") String serviceId){
        Result result  = new Result() ;
        if(StringUtils.isBlank(serviceId)){
            return result.success(tabMarkerColorService.getAllTCType());
        }else{
            return result.success(tabMarkerColorService.getTypeBySet(serviceId));
        }
    }

    /**
     * 获取水位类型
     * @return
     */
    @RequestMapping(value = "/getswclass",method = RequestMethod.GET)
    public Result getSWClass(){
        List<String> staticTypeList = dynamicColumnService.getSWClass();
        return new Result().success(staticTypeList);
    }


}
